home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 1996 July / Macworld (1996-07).dmg / For your System Folder / Sound Manager 3.2a2 / SoundInput.p < prev    next >
Text File  |  1995-11-24  |  11KB  |  310 lines

  1. {
  2.      File:        SoundInput.p
  3.  
  4.      Contains:    Sound Input Interfaces.
  5.  
  6.      Version:    ETO
  7.  
  8.      DRI:        Jim Reekes
  9.  
  10.      Copyright:    © 1984-1995 by Apple Computer, Inc.
  11.                  All rights reserved.
  12.  
  13.      Bugs?:        If you find a problem with this file, use the Apple Bug Reporter
  14.                  stack.  Include the file and version information (from above)
  15.                  in the problem description and send to:
  16.                      Internet:    apple.bugs@applelink.apple.com
  17.                      AppleLink:    APPLE.BUGS
  18.  
  19. }
  20.  
  21. {$IFC UNDEFINED UsingIncludes}
  22. {$SETC UsingIncludes := 0}
  23. {$ENDC}
  24.  
  25. {$IFC NOT UsingIncludes}
  26.  UNIT SoundInput;
  27.  INTERFACE
  28. {$ENDC}
  29.  
  30. {$IFC UNDEFINED __SOUNDINPUT__}
  31. {$SETC __SOUNDINPUT__ := 1}
  32.  
  33. {$I+}
  34. {$SETC SoundInputIncludes := UsingIncludes}
  35. {$SETC UsingIncludes := 1}
  36.  
  37.  
  38. {$IFC UNDEFINED __TYPES__}
  39. {$I Types.p}
  40. {$ENDC}
  41. {    ConditionalMacros.p                                            }
  42.  
  43. {$IFC UNDEFINED __APPLEEVENTS__}
  44. {$I AppleEvents.p}
  45. {$ENDC}
  46. {    Errors.p                                                    }
  47. {    Memory.p                                                    }
  48. {        MixedMode.p                                                }
  49. {    OSUtils.p                                                    }
  50. {    Events.p                                                    }
  51. {        Quickdraw.p                                                }
  52. {            QuickdrawText.p                                        }
  53. {    EPPC.p                                                        }
  54. {        AppleTalk.p                                                }
  55. {        Files.p                                                    }
  56. {            Finder.p                                            }
  57. {        PPCToolbox.p                                            }
  58. {        Processes.p                                                }
  59. {    Notification.p                                                }
  60.  
  61. {$IFC UNDEFINED __WINDOWS__}
  62. {$I Windows.p}
  63. {$ENDC}
  64. {    Controls.p                                                    }
  65. {        Menus.p                                                    }
  66.  
  67. {$IFC UNDEFINED __DIALOGS__}
  68. {$I Dialogs.p}
  69. {$ENDC}
  70. {    TextEdit.p                                                    }
  71.  
  72. {$IFC UNDEFINED __FILES__}
  73. {$I Files.p}
  74. {$ENDC}
  75.  
  76. {$IFC UNDEFINED __SOUND__}
  77. {$I Sound.p}
  78. {$ENDC}
  79. {    Components.p                                                }
  80.  
  81. {$PUSH}
  82. {$ALIGN MAC68K}
  83. {$LibExport+}
  84. {
  85.                         * * *  N O T E  * * *
  86.  
  87.     This file has been updated to include Sound Input Manager 1.1 interfaces.
  88.  
  89.     Some of the Sound Input Manager 1.1 interfaces were not put into the InterfaceLib
  90.     that originally shipped with the PowerMacs. These missing functions and the
  91.     new 1.1 interfaces have been released in the SoundLib library for PowerPC
  92.     developers to link with. The runtime library for these functions are
  93.     installed by Sound Manager 3.2. The following functions are found in SoundLib.
  94.  
  95.         ParseAIFFHeader(), ParseSndHeader()
  96.  
  97. }
  98.  
  99. CONST
  100.     siDeviceIsConnected            = 1;                            {input device is connected and ready for input}
  101.     siDeviceNotConnected        = 0;                            {input device is not connected}
  102.     siDontKnowIfConnected        = -1;                            {can't tell if input device is connected}
  103.     siReadPermission            = 0;                            {permission passed to SPBOpenDevice}
  104.     siWritePermission            = 1;                            {permission passed to SPBOpenDevice}
  105.  
  106. {Info Selectors for Sound Input Drivers}
  107.     siActiveChannels            = 'chac';                        {active channels}
  108.     siActiveLevels                = 'lmac';                        {active meter levels}
  109.     siAGCOnOff                    = 'agc ';                        {automatic gain control state}
  110.     siAsync                        = 'asyn';                        {asynchronous capability}
  111.     siChannelAvailable            = 'chav';                        {number of channels available}
  112.     siCompressionAvailable        = 'cmav';                        {compression types available}
  113.     siCompressionFactor            = 'cmfa';                        {current compression factor}
  114.     siCompressionHeader            = 'cmhd';                        {return compression header}
  115.     siCompressionNames            = 'cnam';                        {compression type names available}
  116.     siCompressionType            = 'comp';                        {current compression type}
  117.     siContinuous                = 'cont';                        {continous recording}
  118.     siDeviceBufferInfo            = 'dbin';                        {size of interrupt buffer}
  119.     siDeviceConnected            = 'dcon';                        {input device connection status}
  120.     siDeviceIcon                = 'icon';                        {input device icon}
  121.     siDeviceName                = 'name';                        {input device name}
  122.     siHardwareBusy                = 'hwbs';                        {sound hardware is in use}
  123.     siInputGain                    = 'gain';                        {input gain}
  124.     siInputSource                = 'sour';                        {input source selector}
  125.     siInputSourceNames            = 'snam';                        {input source names}
  126.     siLevelMeterOnOff            = 'lmet';                        {level meter state}
  127.     siModemGain                    = 'mgai';                        {modem input gain}
  128.     siNumberChannels            = 'chan';                        {current number of channels}
  129.     siOptionsDialog                = 'optd';                        {display options dialog}
  130.     siPlayThruOnOff                = 'plth';                        {playthrough state}
  131.     siRecordingQuality            = 'qual';                        {recording quality}
  132.     siSampleRate                = 'srat';                        {current sample rate}
  133.     siSampleRateAvailable        = 'srav';                        {sample rates available}
  134.     siSampleSize                = 'ssiz';                        {current sample size}
  135.     siSampleSizeAvailable        = 'ssav';                        {sample sizes available}
  136.     siSetupCDAudio                = 'sucd';                        {setup sound hardware for CD audio}
  137.     siSetupModemAudio            = 'sumd';                        {setup sound hardware for modem audio}
  138.     siStereoInputGain            = 'sgai';                        {stereo input gain}
  139.     siTwosComplementOnOff        = 'twos';                        {two's complement state}
  140.     siVoxRecordInfo                = 'voxr';                        {VOX record parameters}
  141.     siVoxStopInfo                = 'voxs';                        {VOX stop parameters}
  142.     siCloseDriver                = 'clos';                        {reserved for internal use only}
  143.     siInitializeDriver            = 'init';                        {reserved for internal use only}
  144.     siPauseRecording            = 'paus';                        {reserved for internal use only}
  145.     siUserInterruptProc            = 'user';                        {reserved for internal use only}
  146. {Qualities}
  147.     siCDQuality                    = 'cd  ';                        {44.1kHz, stereo, 16 bit}
  148.     siBestQuality                = 'best';                        {22kHz, mono, 8 bit}
  149.     siBetterQuality                = 'betr';                        {22kHz, mono, MACE 3:1}
  150.     siGoodQuality                = 'good';
  151.  
  152.     
  153. TYPE
  154.     SPBPtr = ^SPB;
  155.  
  156. {user procedures called by sound input routines}
  157.     {
  158.         SIInterruptProcPtr uses register based parameters on the 68k and cannot
  159.         be written in or called from a high-level language without the help of
  160.         mixed mode or assembly glue.
  161.  
  162.         In:
  163.          => inParamPtr      A0.L
  164.          => dataBuffer      A1.L
  165.          => peakAmplitude    D0.W
  166.          => sampleSize      D1.L
  167.     }
  168.     SIInterruptProcPtr = Register68kProcPtr;  { register PROCEDURE SIInterrupt(inParamPtr: SPBPtr; dataBuffer: Ptr; peakAmplitude: INTEGER; sampleSize: LONGINT); }
  169.     SICompletionProcPtr = ProcPtr;  { PROCEDURE SICompletion(inParamPtr: SPBPtr); }
  170.     SIInterruptUPP = UniversalProcPtr;
  171.     SICompletionUPP = UniversalProcPtr;
  172.  
  173.     SPB = RECORD
  174.         inRefNum:                LONGINT;                                {reference number of sound input device}
  175.         count:                    LONGINT;                                {number of bytes to record}
  176.         milliseconds:            LONGINT;                                {number of milliseconds to record}
  177.         bufferLength:            LONGINT;                                {length of buffer in bytes}
  178.         bufferPtr:                Ptr;                                    {buffer to store sound data in}
  179.         completionRoutine:        SICompletionUPP;                        {completion routine}
  180.         interruptRoutine:        SIInterruptUPP;                            {interrupt routine}
  181.         userLong:                LONGINT;                                {user-defined field}
  182.         error:                    OSErr;                                    {error}
  183.         unused1:                LONGINT;                                {reserved - must be zero}
  184.     END;
  185.  
  186.  
  187. FUNCTION SPBVersion: NumVersion;
  188.     {$IFC NOT GENERATINGCFM}
  189.     INLINE $203C, $0000, $0014, $A800;
  190.     {$ENDC}
  191. FUNCTION SndRecord(filterProc: ModalFilterUPP; corner: Point; quality: OSType; VAR sndHandle: SndListHandle): OSErr;
  192.     {$IFC NOT GENERATINGCFM}
  193.     INLINE $203C, $0804, $0014, $A800;
  194.     {$ENDC}
  195. FUNCTION SndRecordToFile(filterProc: ModalFilterUPP; corner: Point; quality: OSType; fRefNum: INTEGER): OSErr;
  196.     {$IFC NOT GENERATINGCFM}
  197.     INLINE $203C, $0708, $0014, $A800;
  198.     {$ENDC}
  199. FUNCTION SPBSignInDevice(deviceRefNum: INTEGER; deviceName: ConstStr255Param): OSErr;
  200.     {$IFC NOT GENERATINGCFM}
  201.     INLINE $203C, $030C, $0014, $A800;
  202.     {$ENDC}
  203. FUNCTION SPBSignOutDevice(deviceRefNum: INTEGER): OSErr;
  204.     {$IFC NOT GENERATINGCFM}
  205.     INLINE $203C, $0110, $0014, $A800;
  206.     {$ENDC}
  207. FUNCTION SPBGetIndexedDevice(count: INTEGER; VAR deviceName: Str255; VAR deviceIconHandle: Handle): OSErr;
  208.     {$IFC NOT GENERATINGCFM}
  209.     INLINE $203C, $0514, $0014, $A800;
  210.     {$ENDC}
  211. FUNCTION SPBOpenDevice(deviceName: ConstStr255Param; permission: INTEGER; VAR inRefNum: LONGINT): OSErr;
  212.     {$IFC NOT GENERATINGCFM}
  213.     INLINE $203C, $0518, $0014, $A800;
  214.     {$ENDC}
  215. FUNCTION SPBCloseDevice(inRefNum: LONGINT): OSErr;
  216.     {$IFC NOT GENERATINGCFM}
  217.     INLINE $203C, $021C, $0014, $A800;
  218.     {$ENDC}
  219. FUNCTION SPBRecord(inParamPtr: SPBPtr; asynchFlag: BOOLEAN): OSErr;
  220.     {$IFC NOT GENERATINGCFM}
  221.     INLINE $203C, $0320, $0014, $A800;
  222.     {$ENDC}
  223. FUNCTION SPBRecordToFile(fRefNum: INTEGER; inParamPtr: SPBPtr; asynchFlag: BOOLEAN): OSErr;
  224.     {$IFC NOT GENERATINGCFM}
  225.     INLINE $203C, $0424, $0014, $A800;
  226.     {$ENDC}
  227. FUNCTION SPBPauseRecording(inRefNum: LONGINT): OSErr;
  228.     {$IFC NOT GENERATINGCFM}
  229.     INLINE $203C, $0228, $0014, $A800;
  230.     {$ENDC}
  231. FUNCTION SPBResumeRecording(inRefNum: LONGINT): OSErr;
  232.     {$IFC NOT GENERATINGCFM}
  233.     INLINE $203C, $022C, $0014, $A800;
  234.     {$ENDC}
  235. FUNCTION SPBStopRecording(inRefNum: LONGINT): OSErr;
  236.     {$IFC NOT GENERATINGCFM}
  237.     INLINE $203C, $0230, $0014, $A800;
  238.     {$ENDC}
  239. FUNCTION SPBGetRecordingStatus(inRefNum: LONGINT; VAR recordingStatus: INTEGER; VAR meterLevel: INTEGER; VAR totalSamplesToRecord: LONGINT; VAR numberOfSamplesRecorded: LONGINT; VAR totalMsecsToRecord: LONGINT; VAR numberOfMsecsRecorded: LONGINT): OSErr;
  240.     {$IFC NOT GENERATINGCFM}
  241.     INLINE $203C, $0E34, $0014, $A800;
  242.     {$ENDC}
  243. FUNCTION SPBGetDeviceInfo(inRefNum: LONGINT; infoType: OSType; infoData: UNIV Ptr): OSErr;
  244.     {$IFC NOT GENERATINGCFM}
  245.     INLINE $203C, $0638, $0014, $A800;
  246.     {$ENDC}
  247. FUNCTION SPBSetDeviceInfo(inRefNum: LONGINT; infoType: OSType; infoData: UNIV Ptr): OSErr;
  248.     {$IFC NOT GENERATINGCFM}
  249.     INLINE $203C, $063C, $0014, $A800;
  250.     {$ENDC}
  251. FUNCTION SPBMillisecondsToBytes(inRefNum: LONGINT; VAR milliseconds: LONGINT): OSErr;
  252.     {$IFC NOT GENERATINGCFM}
  253.     INLINE $203C, $0440, $0014, $A800;
  254.     {$ENDC}
  255. FUNCTION SPBBytesToMilliseconds(inRefNum: LONGINT; VAR byteCount: LONGINT): OSErr;
  256.     {$IFC NOT GENERATINGCFM}
  257.     INLINE $203C, $0444, $0014, $A800;
  258.     {$ENDC}
  259. FUNCTION SetupSndHeader(sndHandle: SndListHandle; numChannels: INTEGER; sampleRate: UnsignedFixed; sampleSize: INTEGER; compressionType: OSType; baseNote: INTEGER; numBytes: LONGINT; VAR headerLen: INTEGER): OSErr;
  260.     {$IFC NOT GENERATINGCFM}
  261.     INLINE $203C, $0D48, $0014, $A800;
  262.     {$ENDC}
  263. FUNCTION SetupAIFFHeader(fRefNum: INTEGER; numChannels: INTEGER; sampleRate: UnsignedFixed; sampleSize: INTEGER; compressionType: OSType; numBytes: LONGINT; numFrames: LONGINT): OSErr;
  264.     {$IFC NOT GENERATINGCFM}
  265.     INLINE $203C, $0B4C, $0014, $A800;
  266.     {$ENDC}
  267. { Sound Input Manager 1.1 and later calls }
  268. FUNCTION ParseAIFFHeader(fRefNum: INTEGER; VAR sndInfo: SoundComponentData; VAR numFrames: LONGINT; VAR dataOffset: LONGINT): OSErr;
  269.     {$IFC NOT GENERATINGCFM}
  270.     INLINE $203C, $0758, $0014, $A800;
  271.     {$ENDC}
  272. FUNCTION ParseSndHeader(sndHandle: SndListHandle; VAR sndInfo: SoundComponentData; VAR numFrames: LONGINT; VAR dataOffset: LONGINT): OSErr;
  273.     {$IFC NOT GENERATINGCFM}
  274.     INLINE $203C, $085C, $0014, $A800;
  275.     {$ENDC}
  276. CONST
  277.     uppSIInterruptProcInfo = $1C579802; { Register PROCEDURE (4 bytes in A0, 4 bytes in A1, 2 bytes in D0, 4 bytes in D1); }
  278.     uppSICompletionProcInfo = $000000C0; { PROCEDURE (4 byte param); }
  279.  
  280. FUNCTION NewSIInterruptProc(userRoutine: SIInterruptProcPtr): SIInterruptUPP;
  281.     {$IFC NOT GENERATINGCFM }
  282.     INLINE $2E9F;
  283.     {$ENDC}
  284.  
  285. FUNCTION NewSICompletionProc(userRoutine: SICompletionProcPtr): SICompletionUPP;
  286.     {$IFC NOT GENERATINGCFM }
  287.     INLINE $2E9F;
  288.     {$ENDC}
  289.  
  290. PROCEDURE CallSIInterruptProc(inParamPtr: SPBPtr; dataBuffer: Ptr; peakAmplitude: INTEGER; sampleSize: LONGINT; userRoutine: SIInterruptUPP);
  291.     {$IFC NOT GENERATINGCFM}
  292.     {To be implemented:  Glue to move parameters into registers.}
  293.     {$ENDC}
  294.  
  295. PROCEDURE CallSICompletionProc(inParamPtr: SPBPtr; userRoutine: SICompletionUPP);
  296.     {$IFC NOT GENERATINGCFM}
  297.     INLINE $205F, $4E90;
  298.     {$ENDC}
  299.  
  300. {$ALIGN RESET}
  301. {$POP}
  302.  
  303. {$SETC UsingIncludes := SoundInputIncludes}
  304.  
  305. {$ENDC} {__SOUNDINPUT__}
  306.  
  307. {$IFC NOT UsingIncludes}
  308.  END.
  309. {$ENDC}
  310.